package com.itheima.web.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.Banner;
import com.itheima.domain.Movies;
import com.itheima.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(value = "{http://127.0.0.1:81,http://127.0.0.1:82}")
@RestController
@RequestMapping("/banner")
public class BannerManagerController {
    @Autowired
    private BannerService bannerService;
    @RequestMapping("/findByPage")
    //分页查找
    public PageInfo<Banner> findByPage(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "5") Integer pageSize,String keyword){
        return bannerService.findByPage(pageNum,pageSize,keyword);
    }
    //保存
    @RequestMapping("/save")
    public String save(@RequestBody Banner banner){
        //调用方法
        bannerService.save(banner);
        return "ok";
    }
    //回显
    @RequestMapping("findById")
    public Banner findById(Integer id){
        //调用方法
        return bannerService.findById(id);
    }
    //删除
    @DeleteMapping("/deleteById")
    public String deleteById(Integer id){
        //调用方法
        bannerService.deleteById(id);
        return "ok";
    }
    //批量删除
    @DeleteMapping("/deleteIds")
    public String deleteIds(Integer[] ids){
        //调用方法
        bannerService.deleteIds(ids);
        return "ok";
    }
}
